<!DOCTYPE html>
<head>
    <#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
    <#assign secSelect = JspTaglibs["http://www.casic304.cn/secSelect"] />
    <#assign fillDept=JspTaglibs["http://www.casic304.cn/fillDept"] />
    <#assign DutyDept = JspTaglibs["http://www.casic304.cn/DutyDept"]/>
    <meta charset="utf-8">
    <title>不合格品审理基本信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">

    <link rel="stylesheet" href="${ctx}/qbdmsStatic/public/ztree/zTreeStyle.css"/>
    <script src="${ctx}/qbdmsStatic/public/ztree/jquery.min.js"></script>
    <script src="${ctx}/qbdmsStatic/public/ztree/jquery.ztree.all.min.js"></script>

    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-bodyDiv">
    <div class="layui-table-view-body qbdms-add-view-body">
        <form class="layui-form formPreview"  requrl="${ctx}/qbdms/wQbdUnderqualiTrial/get" lay-filter="wQbdUnderqualiTrialDataForm">
            <div class="layui-hide">
                <input type="text" name="id" placeholder="请输入" autocomplete="off" class="layui-input " maxlength="50">
                <input name="filldeptid" value="${filldeptid}" style="display: none"/>
                <input name="filldept" value="${filldept}" style="display: none"/>
                <input name="fillmanaccount" value="${fillmanaccount}" style="display: none"/>
                <input name="fillman" value="${fillman}" style="display: none"/>
                <input name="filldate" value="${filldate}" style="display: none"/>
            </div>
            <div class="qbdms-formTitle">不合格品审理信息 <i class="qbdms-returnOn closeWindow">返回</i></div>
            <div class="qbdms-formBody">
                <div class="layui-row">
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="密级">密级<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <@secSelect.sec_select data_src=1 required=true name="secret" id="secret"/>
                        </div>
                    </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="编号">编号<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="registernum" lay-verify="required" lay-reqtext="编号是必填项" value="${num}" maxlength="20" disabled>
                                </div>
                                <input type="hidden" name="registernumb" value="${numb}">
                            </div>

                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="型号">型号<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <select id="model" name="model" class="layui-input filter-value" lay-search="" lay-verify="required" lay-reqtext="型号是必填项" lay-filter="xh" maxlength="50"></select>
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="产品名称">产品名称<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="productname" lay-verify="required" lay-reqtext="产品名称是必填项" maxlength="32">
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="产品代号">产品代号<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="productsymbol" lay-verify="required" lay-reqtext="产品代号是必填项" maxlength="32">
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="产品编号">产品编号<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="productnum" lay-verify="required" lay-reqtext="产品编号是必填项" maxlength="32">
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="总数量">总数量<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="totalnum" lay-verify="required" lay-reqtext="总数量是必填项" maxlength="32">
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="不合格数量">不合格数量<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请输入" autocomplete="off" class="layui-input textInput" name="unqualifiednum" lay-verify="required" lay-reqtext="不合格数量是必填项" maxlength="32">
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="责任单位"><span style="color: red;">*</span>责任单位</label>
                                <div class="layui-input-block qbdms-input">
                                    <select id="dutydept" name="dutydept" autocomplete="off"
                                            class="layui-input" lay-filter="dutydept"
                                            fieldname="dutydept" lay-verify="required"
                                            lay-reqtext="责任单位是必填项">
                                    </select>
                                </div>
                                <input type="hidden" name="dutydeptname" id="dutydeptname">
                            </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="产品类别">产品类别<span style="color: red;">*</span></label>
                        <div class="layui-input-block qbdms-input">
                            <select id="productcategory" name="productcategory"  lay-filter="cplb1" lay-verify="required" lay-reqtext="产品类别是必填项" lay-search=""></select>
                        </div>
                    </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="审理级别">审理级别</label>
                                <div class="layui-input-block qbdms-input">
                                    <select  id="triallevel" name="triallevel"  lay-filter="triallevel" lay-search=""></select>
                                </div>
                            </div>
                    <div class="qbdms-oneForm">
                        <label class="layui-form-label qbdms-label" title="审理结论">审理结论</label>
                        <div class="layui-input-block qbdms-input">
                            <select id="trialresult" name="trialresult"  lay-filter="cplb2" lay-search=""></select>
                        </div>
                    </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="参与审理人员">参与审理人员</label>
                        <button type="button" typeid="8" class="layui-btn qbdms-twoBtn selectorBtn">选择</button>
                        <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                            <input type="text" name="trialpeople" placeholder="请选择"
                                   autocomplete="off" class="layui-input  selectorInput"
                                   maxlength="500" fieldname="trialpeople" disabled>
                            <input type="hidden" name="trialpeopleid" placeholder="参与审理人员ID"
                                   autocomplete="off" class="layui-input  textInput getIds"
                                   fieldname="${filldeptid}" disabled>
                        </div>
                    </div>
                            <div class="qbdms-textarea">
                                <label class="layui-form-label qbdms-label">不合格品情况描述<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <textarea rows="2" class="layui-textarea" placeholder="请输入" name="underqualidescribe" maxlength="160" lay-verify="required" lay-reqtext="不合格品情况描述是必填项"></textarea>
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="流程状态">流程状态<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <select  id="status" name="status"  lay-filter="status" lay-search="" lay-verify="required" lay-reqtext="流程状态是必填项"></select>
                                </div>
                            </div>
                            <div class="qbdms-oneForm">
                                <label class="layui-form-label qbdms-label" title="审理时间">审理时间<span style="color: red;">*</span></label>
                                <div class="layui-input-block qbdms-input">
                                    <input type="text" placeholder="请选择" autocomplete="off" class="layui-input dateTimeFiled input-right time-init" name="trialtime" maxlength="7">
                                </div>
                            </div>
                            <div class="qbdms-textarea">
                                <label class="layui-form-label qbdms-label">返工、返修、退回供方情况描述</label>
                                <div class="layui-input-block qbdms-input">
                                    <textarea rows="2" class="layui-textarea" placeholder="请输入" name="reworkinfo" maxlength="160"></textarea>
                                </div>
                            </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="责任人">责任人</label>
                        <button type="button" typeid="4" class="layui-btn qbdms-twoBtn selectorBtn">选择</button>
                        <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                            <input type="text" name="dutyperson" readonly="readonly" placeholder="请选择"
                                   autocomplete="off" class="layui-input  selectorInput"
                                   maxlength="30" fieldname="dutyperson">
                            <input type="hidden" name="dutypersonid" placeholder="责任人ID"
                                   autocomplete="off" class="layui-input  textInput getIds"
                                   maxlength="100" fieldname="${filldeptid}">
                        </div>
                    </div>
                            <div class="qbdms-textarea">
                                <label class="layui-form-label qbdms-label">返工、返修、退回供方结果验证</label>
                                <div class="layui-input-block qbdms-input">
                                    <textarea rows="2" class="layui-textarea" placeholder="请输入" name="reworkresultvarify" maxlength="160"></textarea>
                                </div>
                            </div>
                    <div class="qbdms-oneForm  ">
                        <label class="layui-form-label qbdms-label" title="检验员">检验员</label>
                        <button type="button" typeid="4" class="layui-btn qbdms-twoBtn selectorBtn">选择</button>
                        <div class="layui-input-block qbdms-input qbdms-inputIsButton">
                            <input type="text" name="inspector" readonly="readonly" placeholder="请选择"
                                   autocomplete="off" class="layui-input  selectorInput"
                                   maxlength="30" fieldname="inspector">
                            <input type="hidden" name="inspectorid" placeholder="检验员ID"
                                   autocomplete="off" class="layui-input  textInput getIds"
                                   maxlength="100" fieldname="${filldeptid}">
                        </div>
                    </div>
                    <div class="qbdms-textarea">
                        <label class="layui-form-label qbdms-label">不合格品审理单</label>
                        <div class="layui-input-block qbdms-input">
                            <div class="doNotDelThisDiv layui-input-inline">
                                <div class="uploadFileCont">
                                    <input type="button"
                                           class="layui-btn fileUpload qbdms-fileUp iconfont iconupload"
                                           value="上传附件" id="triallistList" name="triallistList">
                                    <i class="qbdms-fileUpText">单个附件，附件格式：doc,docx,pdf，附件大小限制：100M</i>
                                    <input type="text" id="triallist" class="uploadInput" name="triallist" style="display: none">
                                    <div class="uploadFileList" fileUploadName="triallist"></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item btnformItem">
                <p>
                    <span id="hideAndShow" style="">
                        <a lay-submit lay-filter="wQbdUnderqualiTrial" class="layui-btn btn-n privateSubmit qbdms-oneBtn" requrl="${ctx}/qbdms/wQbdUnderqualiTrial/save">保存</a>
                    </span>
                    <button type="reset" id="closeWindow" style="margin-left: 10px;" class="layui-btn layui-btn-sm btn-save qbdms-oneBtnLine">取消</button>
                </p>
            </div>
        </form>
    </div>
</div>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script src="${ctx}/json/comboselect.js" type="text/javascript"></script>
<script>
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'setter', 'layer', 'propsHandle', 'upload', 'common', 'laydate', 'jquery', 'publicMethods', 'qbdmsForm'], function () {
        var $ = layui.jquery,
            laydate = layui.laydate,
            setter = layui.setter,  // 配置信息
            layer = layui.layer,
            common = layui.common,
            propsHandle = layui.propsHandle,
            upload = layui.upload,
            publicMethods = layui.publicMethods,
            formId = '' || '',
            defProps = {
                //viewMould: 'form/formDef/view/formDesign/moulds/', // 组件模块 存放文件 *****
                viewMould: 'moulds/', // 组件模块 存放文件 *****
                initCss: [
                    'style/currencyCss'
                ],
                // formAreaInfo:'.formPreview',
                formAreaInfo: 'html',
                temDate: '.temDate',
                uploadFileBtn: '.uploadFileBtn',
                uploadImgBtn: '.uploadImgBtn',
                richTextArea: '.richTextArea',
                selectInput: '.selectInput',
                radioOptionCont: '.radioOptionCont',
                dataLexiTree: '.dataLexiTree',
                selectorBtn: '.selectorBtn',
            },
            temQuery = new propsHandle(),  // 实例化模板功能部分
            form = layui.qbdmsForm;
        // 初始化模板功能
        temQuery.initTem({
            selectorBtn: defProps.selectorBtn,
            selectorTemPath: setter.views + defProps.viewMould
        });
        //问题责任单位
        var researchRoomList =${researchRoomList};
        var researchRoom = function(optionObj, item){
            optionObj.text = item.orgName;
            optionObj.value = item.code;
        };
        common.initDicData("dutydept", researchRoomList, "", researchRoom);

        // 型号代号
        var xhdh = eval('${wQbdXhdhs}'); //型号代号
        var initXHDH = function (optionObj, item) {
            optionObj.text = item.fModelcode;
            optionObj.value = item.fModelcode;
            optionObj.setAttribute("xhmc", item.fModelname);
        };
        common.initDicData("model", xhdh, "", initXHDH);

        $(".subContTem").hide()
        // 子表初始化事件
        temQuery.initSubEvent(defProps, serverPath, setter);
        var dateTimeFiledLen = $(".dateTimeFiled");
        for (var i = 0; i < dateTimeFiledLen.length; i++) {
            laydate.render({
                elem: dateTimeFiledLen[i] //指定元素
                , type: 'date'
                , trigger: 'click'
            });
        }
        //- 添加表单验证规则 开始 ---------------------------------------------------------------------
        form.verify({
            length100:[/^.{0,100}$/,'输入字符数不能超过100'],
            length2000:[/^.{0,2000}$/,'输入字符数不能超过2000'],
            fileRequired: function (value,item) {
                value = $(item).siblings(".uploadInput").val()
                if(!new RegExp(/[\S]+/).test(value)){
                    return common.verifyTitleAdd(item) +"没有上传对应附件"
                }
            },
            money: function (value,item) {
                if (value && !new RegExp(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/).test(value)) {
                    return common.verifyTitleAdd(item) +'请输入数字且小数最多两位';
                }
            },
            integer: function (value,item) {
                if (value && !new RegExp(/^[+]{0,1}(\d+)$/).test(value)) {
                    return common.verifyTitleAdd(item) + '请输入正整数';
                }
            }
        });
        //- 添加表单验证规则 结束 ---------------------------------------------------------------------

        //关闭当前页面
        $("#closeWindow,.closeWindow").click(function () {
            window.location.href = '${ctx}/qbdms/wQbdUnderqualiTrial/view/list';
        });

        //下载附件
        window.downFile = function (obj) {
            var fileId = $(obj).parents("span").attr("fileId");
            window.location.href = serverPath.qbdmsPath + setter.extendLinkPath + "attachFile/download?fileId=" + fileId;
        }
        // 删除
        $(document).on('click', '.deleteFile', function () {
            $(this).parent().parent().siblings("button").show()
            $(this).parent().remove();
            $(".uploadFileList").each(function (i, v) {
                common.constructFileStr(v)
            });
        });

        // 检验员默认当前登录人
        var id = "${id}";
        if (id == null || id == '') {
            $("input[name='inspector']").val('${fillman}');
            $("input[name='inspectorid']").val('${fillmanid}');
        }

        var runId = "${runId}";
        if(runId == null || runId == ''){
            $("#hideAndShow").show();
        }
        form.on('select(dutydept)', function (data) {
            $("#dutydeptname").val(data.elem[data.elem.selectedIndex].text);
        });

        var common = layui.common;
        var index = parent.layer.getFrameIndex(window.name);
        common.updateForm({
            name:'wQbdUnderqualiTrialDataForm',
            idValue:"${id}",
            primary:"id",
            beforeSubmitFun: function (data) {
                //- 附件密级不能高于表单密级 开始 ------------------------------------------------------
                var selectMaxVal = 0;
                var formSecretVal = $("[name='secret']").val();
                $(".fileSecLevel select").each(function () {
                    selectMaxVal = selectMaxVal >= $(this).val() ? selectMaxVal : $(this).val();
                });

                if (selectMaxVal > formSecretVal) {
                    layer.msg('附件密级不能高于表单密级。', {icon: 5});
                    return false;
                }
                //- 附件密级不能高于表单密级 结束 ------------------------------------------------------
                $(".uploadFileList").each(function (i, v) {
                    common.constructFileStr(v)
                });
                var files=[];
                //整理上传附件的隐藏域，将提交的字符串转为json对象
                $(".uploadInput").each(function () {
                    var uploadName = $(this).attr("name");
                    if (!$(this).val()) {
                        return;
                    }
                    data.field[uploadName] = eval($(this).val());
                    files=files.concat(eval($(this).val()));
                });

                return common.setFileLevel(files);

            },
            getCallback: function (data) {
                $("input[name='trialpeople']").attr("ids", data.data.trialpeopleid);
                $("input[name='dutyperson']").attr("ids", data.data.dutypersonid);
                $("input[name='inspector']").attr("ids", data.data.inspectorid);

                $("#tbxx").html("<span class='qbdms-TBinformation'>填报信息:</span><span class='qbdms-TBinformationText'>【" + data.data.filldept + " | " + data.data.fillman + " | " + data.data.filldate + "】</span>");

                $('.uploadFileList').each(function () {
                    var fileUploadName = $(this).attr("fileUploadName");
                    var jsonFile = data.data[fileUploadName];
                    var files = eval(jsonFile);

                    if (files) {
                        for (var i = 0; i < files.length; i++) {
                            var fileLevel = files[i].fileLevel;
                            var fileLevelText = files[i].fileLevelText;
                            var fileSec = '<div class="fileSecLevel fileSecXg layui-input-inline">' + '<@secSelect.sec_select data_src=1 hasBlank=false/>' + "</div>";
                            var newStr = '<span class="file-id" style="margin-right: 20px;" fileId=' + files[i].fileId + ' fileLevelText="' + fileLevelText + '">' + fileSec + '<span class="file-name" title="点击下载文件" onclick="downFile(this)"><i class="iconfont" style="margin-right: 5px"></i>' + files[i].fileName + '</span></span>';
                            $(this).html(newStr);
                            $(this).find("select:last").val(fileLevel);
                            $(this).find("select:last").attr("disabled", "disabled");
                        }
                    } else {
                        $(this).html("<span style='color: #c0c4cc'>未上传</span>");
                    }
                });
                //-修改页面 级联下拉 原因分类 开始 ------------------------------------------
                comboselect.setDefaultValueByArr(data.data["productcategory"], data.data["trialresult"]);
                form.render("select");
                //-修改页面 级联下拉 原因分类 结束 ------------------------------------------
            },
            updateCallback:function (data) {
                if (publicMethods._filterRecord(data)) {
                    if ($(".privateSubmit")) {
                        $(".privateSubmit").attr("disabled", false).css("pointer-events", "auto");
                    }
                    layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'}, function (index) {
                        layer.close(index);

                            window.location.href = '${ctx}/qbdms/wQbdUnderqualiTrial/view/list';
                    });
                } else {
                    layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'});
                }
                return false;
            }
        });

        //- 知识分类初始化 绑事件 开始 -------------------------------------------------------------
        var sljbList = eval('${sljbList}'); //审理级别
        common.initDicData("triallevel", sljbList);

        var lcztList = eval('${lcztList}'); //流程状态
        common.initDicData("status", lcztList);

        var cplbList = eval('${cplbList}'); //知识分类
        var typeId = "${typeId}";
        comboselect = ComboSelectFactory(cplbList, 'productcategory', 'trialresult');
        comboselect.setProperties({
            idKey: 'dicId',
            valueKey: 'itemName',
            textKey: 'itemName',
            parentIdKey: 'parentId',
            topParentValue: typeId
        });
        form.render("select");
        form.on('select(cplb1)', function(){
            comboselect.eventHandle(document.getElementById("productcategory"),0)();
            form.render("select");
        });

        var secSelect = '<@secSelect.sec_select data_src=1 hasBlank=false/>'
        common.uploadfun(".fileUpload", {
            acceptMime: 'application/pdf, application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document',
            exts: "doc|docx|pdf",
            secSelect: secSelect,
            isSub: false,
            upLoadSize:102400,
            upLoadNumber: 1,
            isMultiFile: false
        });

        publicMethods.bottomFixd()
        form.on('select', function (data) {
            publicMethods.bottomFixd()
        });
        form.render();

    });
</script>
</body>
</html>